<?php
/***************************************************************************
*                            Dolphin Smart Community Builder
*                              -------------------
*     begin                : Mon Mar 23 2006
*     copyright            : (C) 2007 BoonEx Notice
*     website              : http://www.boonex.com
* This file is part of Dolphin - Smart Community Builder
*
* Dolphin is free software; you can redistribute it and/or modify it under
* the terms of the GNU General Public License as published by the
* Free Software Foundation; either version 2 of the
* License, or  any later version.
*
* Dolphin is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY;
* without even the implied warranty of  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
* See the GNU General Public License for more details.
* You should have received a copy of the GNU General Public License along with Dolphin,
* see license.txt file; if not, write to marketing@boonex.com
***************************************************************************/

bx_import('BxDolTwigPageMain');

class BxNoticesPageMain extends BxDolTwigPageMain {

    function BxNoticesPageMain(&$oMain) {

		$this->_oDb = $oMain->_oDb;
        $this->_oConfig = $oMain->_oConfig;

        $this->sSearchResultClassName = 'BxNoticesSearchResult';
        $this->sFilterName = 'modzzz_notices_filter';
		parent::BxDolTwigPageMain('modzzz_notices_main', $oMain);
	}
   
    function getBlockCode_LatestFeaturedTravel() { 
        return $this->ajaxBrowse('featured_travel', 1);
    }

    function getBlockCode_LatestFeaturedAvailability() { 
        return $this->ajaxBrowse('featured_available', 1);
    }

    function getBlockCode_RecentTravel() { 
        return $this->ajaxBrowse('recent_travel', $this->oDb->getParam('modzzz_notices_perpage_main_recent'));
    }

    function getBlockCode_RecentAvailable() { 
        return $this->ajaxBrowse('recent_available', $this->oDb->getParam('modzzz_notices_perpage_main_recent'));
    }


	function getBlockCode_Popular() { 
        return $this->ajaxBrowse('popular', $this->oDb->getParam('modzzz_notices_perpage_main_recent'));
    }
    
	function getBlockCode_Top() { 
        return $this->ajaxBrowse('top', $this->oDb->getParam('modzzz_notices_perpage_main_recent'));
    }

	function getBlockCode_Create() {
   		
		$sAskUrl = BX_DOL_URL_ROOT . $this->oConfig->getBaseUri() . 'browse/my&modzzz_notices_filter=add_notice'; 
    
		$aVars = array( 
			'create_url' => $sAskUrl, 
  		);
 
		$sCode = $this->oTemplate->parseHtmlByName('create_notice', $aVars);  

		return $sCode;
	}

 	function getBlockCode_CalendarTravel() {  
	   $oMain = BxDolModule::getInstance('BxNoticesModule');
	   $iYear=(int)date("Y");
	   $iMonth=(int)date("m");
	   
		$sCode = "<div id='cal_travel_block'>";
		$sCode .= $oMain->displayMainCalendarTravel($iYear, $iMonth, _t('_modzzz_notices_calendar'));
		$sCode .= "</div>";

		return $sCode;
    }

	function getBlockCode_CalendarAvailable() {  
	   $oMain = BxDolModule::getInstance('BxNoticesModule');
	   $iYear=(int)date("Y");
	   $iMonth=(int)date("m");
	   
		$sCode = "<div id='cal_available_block'>";
		$sCode .= $oMain->displayMainCalendarAvailable($iYear, $iMonth, _t('_modzzz_notices_calendar'));
		$sCode .= "</div>";

		return $sCode;
    }

	function getBlockCode_Search() {
		
		$sSearchUrl = BX_DOL_URL_ROOT . $this->oConfig->getBaseUri() . 'browse/quick/'; 
	
		$aVars = array( 
			'search_url' => $sSearchUrl, 
		);
 
		$sCode = $this->oTemplate->parseHtmlByName('search_notices', $aVars);  

		return $sCode;
	} 

    function getBlockCode_Tags($iBlockId) { 
        bx_import('BxTemplTagsModule');
        $aParam = array(
            'type' => 'modzzz_notices',
            'orderby' => 'popular',
			'pagination' => getParam('tags_perpage_browse')
        );

		$sUrl = BX_DOL_URL_ROOT . $this->oConfig->getBaseUri() . 'tags';
  
        $oTags = new BxTemplTags();
        $oTags->getTagObjectConfig();
    
        return array(
            $oTags->display($aParam, $iBlockId, '', $sUrl),
            array(),
            array(),
            _t('_Tags')
        ); 

    }  
 
	function getNoticesMain() {
        return BxDolModule::getInstance('BxNoticesModule');
    }
 

}

?>